home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
- Newsgroups: comp.lang.c++
- Subject: Re: Is it OK to delete const *type pointers?
- Date: Thu, 04 Apr 1996 17:19:13 +0200
- Organization: Fachbereich Informatik, TH Darmstadt
- Message-ID: <3163E871.237C228A@intellektik.informatik.th-darmstadt.de>
- References: <4jhjub$fpc@mag1.magmacom.com>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01 (X11; I; SunOS 4.1.3 sun4m)
-
- Acme Instant Dehydrated Boulder Kit wrote:
- >
- > Some compilers let me do this, others do not. What I would like to know is,
- > what does Stroustrup think? I.e. is it written somewhere in the ARM (I checked
- > but can't find it) or in the draft standard? If somoene could e-mail me a
- > quote or a pointer to a place where I can read where it says such a thing
- > should or should not be allowed, I would appreciate it!
- >
- > const int* array= new int[30];
- > delete[] array;
- >
- > MSVC says "can not delete const*"
- > Some versions of G++ also don't let me do this.
- >
- > Is deleting an object technically considered changing that object's value?
- >
-
- The standard doesn't specify this (5.3.5.4):
- ... It is unspecified whether the deletion of an object changes its
- value. ...
-
- According to the DWP a dtor can be invoked even for a const-object
- (12.4 class.dtor). Thus I would say the above code should compile.
-
- Enno
-